package com.medical.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.medical.admin.domain.vo.GuidePageVO;
import com.medical.admin.service.SearchService;
import com.medical.common.core.domain.Result;
import com.medical.admin.domain.GuidePage;
import com.medical.admin.service.GuideService;
import com.medical.common.core.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @BelongsProject: Medical
 * @BelongsPackage: com.medical.system.controller
 * @Author: LX
 * @CreateTime: 2025-02-26  20:30
 * @Description: TODO
 * @Version: 1.0
 */

@RestController
public class ManageController {
    @Autowired
    private GuideService guideService;

    /**
     * 引导页
     * @return
     */
    @GetMapping("/guidePage")
    public Result<List<GuidePageVO>> getGuidePage() {
        LambdaQueryWrapper<GuidePage> wrapper = new LambdaQueryWrapper<>();
        //先判断图片类型，然后根据字段排序
        wrapper.eq(GuidePage::getType,0);
        wrapper.eq(GuidePage::getIsExists,0);
        wrapper.orderByAsc(GuidePage::getPageSort);
        List<GuidePage> list = guideService.list(wrapper);
        List<GuidePageVO> guidePageVOS = new ArrayList<>();
        list.forEach(item->{
            GuidePageVO guidePageVO = new GuidePageVO();
            BeanUtils.copyProperties(item,guidePageVO);
            guidePageVOS.add(guidePageVO);
        });
        return Result.success(guidePageVOS);
    }

    /**
     * 首页轮播图
     * @return
     */
    @GetMapping("/carousel")
    public Result<List<GuidePageVO>> getCarousel() {
        LambdaQueryWrapper<GuidePage> wrapper = new LambdaQueryWrapper<>();
        //先判断图片类型，然后根据字段排序
        wrapper.eq(GuidePage::getType,1);
        wrapper.eq(GuidePage::getIsExists,0);
        wrapper.orderByAsc(GuidePage::getPageSort);
        List<GuidePage> list = guideService.list(wrapper);
        List<GuidePageVO> guidePageVOS = new ArrayList<>();
        list.forEach(item->{
            GuidePageVO guidePageVO = new GuidePageVO();
            BeanUtils.copyProperties(item,guidePageVO);
            guidePageVOS.add(guidePageVO);
        });
        return Result.success(guidePageVOS);
    }








}
